package cn.ulegal.xudy.Dao.DaoImpl;

import cn.ulegal.xudy.Dao.TestDao;
import cn.ulegal.xudy.Service.TestService;
import cn.ulegal.xudy.entity.TestModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
import org.springframework.stereotype.Repository;

/**
 * Created by Ulegal on 2017/8/18.
 */
@Repository
public class TestDaoImpl<T> implements TestDao<T>{


    @Autowired
    JdbcTemplate jdbcTemplate;

    @Override
    public Integer saveOidInfo(T model) {

        SimpleJdbcInsert insert = new SimpleJdbcInsert(jdbcTemplate);
        insert.withTableName("ceshi0");
        SqlParameterSource source = new BeanPropertySqlParameterSource(model);
        Number newId = insert.execute(source);

        return newId.intValue();
    }
}
